﻿
<%@page import="com.lmpop.trade.ti_voucher.Ti_voucherInfo"%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.lmpop.trade.ts_area.*" %>
<%@ page import="com.lmpop.createIndex.search.*" %>
<%@ page import="com.lmpop.trade.shopcart.*"%>
<%
    
	request.setCharacterEncoding("UTF-8");
	
	String consignee="",area_attr="",post_code="",tel="",cellphone="",address="";
	if(request.getParameter("consignee") != null){consignee = request.getParameter("consignee");}
	if(request.getParameter("area_attr") != null){area_attr = request.getParameter("area_attr");}
	if(request.getParameter("post_code") != null){post_code = request.getParameter("post_code");}
	if(request.getParameter("tel") != null){tel = request.getParameter("tel");}
	if(request.getParameter("cellphone") != null){cellphone = request.getParameter("cellphone");}
	if(request.getParameter("address") != null){address = request.getParameter("address");}
	CartServices shopcart = null;
	String voucherinfos="";
	if(session.getAttribute("shoppingCart") != null) {
	  	shopcart = (CartServices) session.getAttribute("shoppingCart");
	  	voucherinfos=shopcart.getAllItemsDiscountids();
	} 
	
	AreaIndexFiles areaBean = new AreaIndexFiles();
	
	String areaoutput="";
	if(!area_attr.equals(""))
	{
	   String areaArr[] = area_attr.split("\\|");
	   for( int k = 0; k < areaArr.length; k++)
	   {
		  if( k == areaArr.length-1)
		  {
		       areaoutput +=  areaBean.getAreaNameById(areaArr[k]);	 		
		  }
		  else
		  {
		       areaoutput +=  areaBean.getAreaNameById(areaArr[k])+ "-";
          }		  
	   }
	}
	String user_id = "";	
	if( session.getAttribute("session_user_id") != null ){
		user_id = session.getAttribute("session_user_id").toString().trim();
	}
	
	PaymentIndexFiles paymentIndex = new PaymentIndexFiles();
	ShipingIndexFiles shipingIndex = new ShipingIndexFiles();
	CommparaIndexFiles commparaIndex = new CommparaIndexFiles();
   
    Map shippingSearchMap = new Hashtable();
	List shipingList = shipingIndex.getShipingInfo(shippingSearchMap);
  


%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>配送地址</title>

<link href="/templets/html/shop/css/mall_top.css" rel="stylesheet" type="text/css" />
<link href="/templets/html/shop/css/qd.css" rel="stylesheet" type="text/css" />
<link href="/templets/html/shop/css/mall_bottom.css" rel="stylesheet" type="text/css" />
<link href="/templets/html/shop/css/style.css" rel="stylesheet" type="text/css" />
<link  href="/templets/html/shop/css/Home.css" rel="stylesheet"/>
<SCRIPT src="/templets/html/shop/js/taobao.js"></SCRIPT>
<SCRIPT src="/templets/html/shop/js/nav_style_num.js"></SCRIPT>
		<script type='text/javascript' src='/dwr/engine.js'></script>
		<script type='text/javascript' src='/dwr/util.js'></script>
		<script type='text/javascript' src='/dwr/interface/Ti_subscribeInfo.js'></script> 
		<script type='text/javascript' src='/templets/html/shop/js/_shop.js'></script>
<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/interface/Ti_voucherInfo.js'></script>
<style type="text/css">
<!--
.STYLE1 {color: #FFFFFF}
-->
</style>
</head>

<body>


<script> 
  document.write("<s" + "cript type='text/javascript' src='/templets/html/shop/top.jsp?" + Math.random() + "'></scr" + "ipt>"); 
  TB.Header.init(); 
</script>
<!--导航结束-->

<div class="clear"></div>




<div class="clear"></div>
<!--提交订单开始-->
<!--<div class="tjdd">
  <ul>
    <li><img src="/templets/html/images/dd_07.gif" /></li>
    <li class="dd_zc">登录注册</li>
    <li class="dd_jt"><img src="/templets/html/shop/images/dd_14.gif" /></li>
    <li class="dd_num"><img src="/templets/html/shop/images/dd_10.gif" /></li>
    <li class="dd_qr dd_tj">确认订单信息</li>
    <li class="dd_jt"><img src="/templets/html/shop/images/dd_17.gif" /></li>
    <li class="dd_num"><img src="/templets/html/shop/images/dd_12.gif" /></li>
    <li class="dd_zc">提交订单</li>
  </ul>
</div> -->
<div class="clear"></div>



 <div class="content0">
    <div class="chengxu">
      <div class="chengxu_m">
        <ul>
          <li class="txt_li">登录/注册<small>login/regist</small><img align="absmiddle" src="/templets/html/shop/images/jiantou.gif" /></li>
          <li class="txt_li">我的购物车<small>shopping cart</small><img align="absmiddle" src="/templets/html/shop/images/jiantou_l.gif" /></li>
          <li class="tex_current">填写订单信息<small>order information</small><img align="absmiddle" src="/templets/html/shop/images/jiantou_r.gif" /></li>
          <li class="txt_li">提交订单,付款<small>submit/pay</small><img align="absmiddle"src="/templets/html/shop/images/jiantou.gif" /></li>
          <li class="txt_li">等待收货<small>wait for delivery</small></li>
        </ul>
      </div>
    </div>


<form action="/templets/html/order/order_sub.jsp" method="post" name="subAgainForm">
<div class="content">
	<div class="add_c">
		<div class="add_dz">
             <div class="titleqd"><p><span class="titleqd_sp">收货人信息</span>
			 <span class="p_l">[<a href="/templets/html/shop/jsp/confirm_order_address.jsp#hasaddress">修改</a>]</span></p></div>
             <div class="deta">
                <p><span class="deta_sp">收货人：<%=consignee%></span>
				 <span class="deta_sp">地区：<%=areaoutput%></span>
				 <span class="deta_sp">邮政编码：<%=post_code%></span></p>
				 <p><span class="deta_sp">收货地址：<%=address%></span>
				 <span class="deta_sp">固定电话：<%=tel%></span>
				  <span class="deta_sp">移动电话：<%=cellphone%></span></p>
             </div>
             <div class="titleqd">
			 <p><span class="titleqd_sp">配送方式</span>
			 <%
				int shipingSize = 0;
				shipingSize = shipingList.size();
				String ship_name="",shipping_id="";	
				if(shipingList!=null && shipingSize>0)
				{
					for(int i=0;i<shipingSize;i++){
						Hashtable map = (Hashtable)shipingList.get(i);
				  			
						if(map.get("ship_name")!=null) ship_name = map.get("ship_name").toString();
						if(map.get("shipping_id")!=null) shipping_id = map.get("shipping_id").toString();
		
		      %>
				
			 <span class="p_l"><input type="radio"  name="ship_name" id="shipping_id<%=i%>" value="<%=ship_name%>" checked /><%=ship_name%>
				  </span>
			<%
				    }
				 }
				%>
				<input type="hidden" name="shipsize" id="shipsize" value="<%=shipingSize%>" />
			 </div>
             <div class="clear"></div>
             
			 <%
				Map paymentSearchMap = new Hashtable();
				paymentSearchMap.put("cust_id","100000000000000");
				List paymentList = paymentIndex.getPaymentInfo(paymentSearchMap);
				%>
			  
             <%
				if(voucherinfos!=null&&!"".equals(voucherinfos)){%>
					 <div class="titleqd"><p><span class="titleqd_sp">优惠券</span>&nbsp;&nbsp;&nbsp;
						<select name="voucher_ids" id="voucher_ids" onclick="setVoucherInfo()">
							<option value="">请选择</option>
							<%=voucherinfos %>
						</select>
						<input type="text" size="5" name="voucher_num" id="voucher_num" value="" onkeyup="setVoucherInfo()"/>张
						<input type="hidden" name="voucherinfos" id="voucherinfos" />
						<input type="hidden" name="voucherinfos2" id="voucherinfos2" />
					 </div>
				<%}else{%>

						<input type="hidden" name="voucherinfos" id="voucherinfos" />
						<input type="hidden" name="voucherinfos2" id="voucherinfos2" />
						<input type="hidden" name="voucher_ids" id="voucher_ids" />
				<%}
			 %>
			
			 
			 
			 <div class="clear"></div>
             <div class="titleqd_last">
			 <%
		    Map commMap = new Hashtable();
			commMap.put("param_attr","25");
			//commMap.put("para_code3","1");
			List packageList = commparaIndex.getCommparaInfo(commMap);
			%>
			 <p><span class="titleqd_sp">包装方式</span>  
			 <%
						   int packlistsize = 0;
						  
						   if(packageList!=null && packageList.size()>0){
							  packlistsize = packageList.size();
							  for(int i=0;i<packageList.size();i++){
							    String para_code1="",para_code2="",para_code3="";
								Hashtable map = (Hashtable)packageList.get(i);
								if(map.get("para_code1")!=null) para_code1 = map.get("para_code1").toString();
								if(map.get("para_code2")!=null) para_code2 = map.get("para_code2").toString();
								if(map.get("para_code3")!=null) para_code3 = map.get("para_code3").toString();
						
		
		                %>
						<span class="p_l">
						<input name="para_code3" id = "para_code3<%=i%>"  type="radio" value="<%=para_code3%>"  <%if(i==0)out.print("checked");%> /><%=para_code1%></span>
					</span><input type="hidden" name="para_code1<%=i%>" id="para_code1<%=i%>" value="<%=para_code1%>" />
					<input type="hidden" name="para_code2<%=i%>" id="para_code2<%=i%>" value="<%=para_code2%>" /></span>
						 <%
			 } 
		  }
		
		%>	
			</p>
			</div>

		
		<input type="hidden" name="packsize" id="packsize" value="<%=packlistsize%>" />
             <div class="clear"></div>
			 <div class="clear"></div>
			 
			 <div class="clear"></div>
             <div class="titleqd_last">
			 <p><span class="titleqd_sp">送货时间</span>  
			 <span class="p_l"><input name="best_time" type="radio" value="工作日、双休日与假日均可送货" checked />工作日、双休日与假日均可送货</span>
			 <span class="p_l"> <input name="best_time" type="radio" value="只有双休日、假日送货（工作日不用送货）"/>只有双休日、假日送货（工作日不用送货）</span>
			 <span class="p_l"><input name="best_time" type="radio" value="只有工作日送货（双休日、假日不用送）"/>只有工作日送货（双休日、假日不用送）</span>
			 </p></div>
             <div class="clear"></div>
	    </div>
	
	</div>
</div>
 <input type="hidden" name="area_attr" id="put_area_attr" value="<%=area_attr%>" />
   <input type="hidden" name="consignee" id="put_consignee" value="<%=consignee%>" />
   <input type="hidden" name="post_code" id="put_post_code" value="<%=post_code%>" />
   <input type="hidden" name="tel" id="put_tel" value="<%=tel%>" />
   <input type="hidden" name="cellphone" id="put_cellphone" value="<%=cellphone%>" />
   <input type="hidden" name="address" id="put_address" value="<%=address%>" />
   
   <input type="hidden" name="ship_name" id="ship_name" value="<%=ship_name%>" />
   <input type="hidden" name="shipping_id" id="shipping_id" value="<%=shipping_id%>" />
   
    
   
   <input type="hidden" name="para_code1" id="para_code1" value="" />
   <input type="hidden" name="para_code2" id="para_code2" value="" />
   
   
    <input type="hidden" name="type_order" id="type_order" value="1" />


</form>
</p>
<script>
	var flag=true;
function subInfo()
{
   var packsize = document.getElementById("packsize").value;
   for(var i=0;i<packsize;i++)
   {
     var para_code3 = document.getElementById("para_code3"+i);
	 if(para_code3.checked)
	  {
	     document.getElementById("para_code1").value = document.getElementById("para_code1"+i).value
		 document.getElementById("para_code2").value = document.getElementById("para_code2"+i).value
	  }
   
   }
	
	document.subAgainForm.submit();

   
   
}

function setVoucherInfo(){
		var value="",text="",numstr;
		var voucherinfos="";
	    var num=document.getElementById("voucher_num").value;
		var val=document.getElementById("voucher_ids");
		var str="";

	 for(var i=0;i<val.length;i++){   
                if(val.options[i].selected){    	
                	text=val.options[i].text;
                	value=val.options[i].value;
                	if(value!=""){
                		 numstr=parseInt(text.substring(text.indexOf("|")+1,text.length));
						if(num==""){
							break;
						} 
	                	if(num>numstr){	
	                		alert("您输入的优惠券张数已经超过");
	                		break;
	                	}
						
						Ti_voucherInfo.checkVoucherStockNum(value,function(data){
								if(data<num){
									flag=false;
									voucherinfos="";
									str="";
									alert("当前可用的优惠券已经不足支付");
									document.getElementById("voucher_num").focus();
									return;
								}else{
									flag=true;
									voucherinfos +=value+":"+num+"|";
									str +=text.replace("|"+numstr,"")+":"+num+"|";
									
								}
								document.getElementById("voucherinfos").value=voucherinfos;
								document.getElementById("voucherinfos2").value=str;
						});                	
	                }
                	
                }
            }
			
}

</script>

<div class="clear"></div>

<div class="qd_qr"><a href="###" onclick="subInfo();"><img src="/templets/html/shop/images/time.jpg" /></a></div>
<!--<div class="qd_qr">请核对以上信息，确认无误后点击“提交订单”<img src="/templets/html/images/dd_28.jpg" /></div>-->


<!--广告开始-->
<div class="commitment">
	    <div class="commitment_left">
		    <div class="commitment_pic"><a href=""><img src="/templets/html/shop/images/commitment_1.jpg" /></a></div>
			<div class="commitment_txt"><p><span class="commitment_txt1">全国900个城市货到付款</span><span class="commitment_txt2"></span></p>
			</div>
		</div>
		
		<div class="commitment_center">
		    <div class="commitment_pic"><a href=""><img src="/templets/html/shop/images/commitment_2.jpg" /></a></div>
			<div class="commitment_txt3"><p><span class="commitment_txt1">购买满200免运费</span><span class="commitment_txt2"></span></p></div>
		</div>
		
		<div class="commitment_right">
		    <div class="commitment_pic"><a href=""><img src="/templets/html/shop/images/commitment_3.jpg" /></a></div>
			<div class="commitment_txt4"><p><span class="commitment_txt1">30天无忧退换货保障</span><span class="commitment_txt2"></span><span class="commitment_txt1"></span></p></div>
		</div>
</div>
<!--广告结束-->


<div class="clear"></div>
<!--底部开始-->
	<jsp:include page="/templets/html/shop/footer.jsp"/>
<!--底部结束-->




</body>
</html>
